package com.group.his.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.group.his.entity.Department;
import com.group.his.entity.Register;
import com.group.his.entity.User;
import com.group.his.mapper.BPatientcostsMapper;
import com.group.his.mapper.BRegisterMapper;
import com.group.his.mapper.BRegistlevelMapper;
import com.group.his.service.BDepartmentService;
import com.group.his.service.BRegisterService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 */
@Service
public class BRegisterServiceImpl extends ServiceImpl<BRegisterMapper, Register> implements BRegisterService {
     @Resource
    BRegistlevelMapper bRegistlevelMapper;
     @Resource
    BPatientcostsMapper bPatientcostsMapper;
     @Resource
    BDepartmentService bDepartmentService;
    @Resource
    com.group.his.service.BUserService bUserService;
    @Resource
    BRegisterMapper bRegisterMapper;
    @Override
    public Object getRegistCostById(int id) {
        return   bRegistlevelMapper.selectById(id).getRegistFee();
    }

    @Override
    public Object getPatientByIdNum(String idNum) {
        QueryWrapper<Register> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq(Register.IDNUMBER,idNum);
        return list(queryWrapper).get(0);
    }

    @Override
    public List<Department> getAllDepartment() {
        QueryWrapper<Department> queryWrapper=new QueryWrapper<>();
        return  bDepartmentService.list(queryWrapper);
    }
    public List<User> getDoctorByDepidLevelid(int depid, int levelId){
        QueryWrapper<User> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq(com.group.his.entity.User.DEPTID,depid);
        queryWrapper.eq(com.group.his.entity.User.REGISTLEID,levelId);
        return bUserService.list(queryWrapper);
    }
    public Object regist(Register register) {
        return   bRegisterMapper.insert(register);
    }

}
